package cn.com.thingo.hyintelligent.model.http.api;


import java.util.List;

import cn.com.thingo.hyintelligent.model.bean.BaseBean;
import cn.com.thingo.hyintelligent.model.bean.CommonBean;
import cn.com.thingo.hyintelligent.model.bean.EzAccountBean;
import cn.com.thingo.hyintelligent.model.bean.DoorLockAuthBean;
import cn.com.thingo.hyintelligent.model.bean.EzAddDevicePermissionBean;
import cn.com.thingo.hyintelligent.model.bean.EzDeleteDevicePermissionBean;
import cn.com.thingo.hyintelligent.model.bean.EzDeviceAuthorizationListBean;
import cn.com.thingo.hyintelligent.model.bean.EzDevicePolicyBean;
import cn.com.thingo.hyintelligent.model.bean.EzDeviceStateBean;
import cn.com.thingo.hyintelligent.model.bean.GatewayDetailBean;
import cn.com.thingo.hyintelligent.model.bean.GatewayListBean;
import cn.com.thingo.hyintelligent.model.bean.GetEzTokenBean;
import cn.com.thingo.hyintelligent.model.bean.LoginBean;
import cn.com.thingo.hyintelligent.model.bean.MessageCountBean;
import cn.com.thingo.hyintelligent.model.bean.MessageListBean;
import cn.com.thingo.hyintelligent.model.bean.ModifyHeadBean;
import cn.com.thingo.hyintelligent.model.bean.RegisterBean;
import cn.com.thingo.hyintelligent.model.bean.UserBean;
import io.reactivex.Flowable;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Query;

/**
 * Created by Administrator on 2017/10/17.
 */

public interface ShouCheApis {

    //服务器配置
    String HOST = "http://haiy.dhcthink.cn/Mobile/";
    String HOST_ = "http://haiy.dhcthink.cn/";

    //获取手机验证码
    @FormUrlEncoded
    @POST("Login/telCode")
    Flowable<CommonBean> getCode(
            @Field("telephone") String telephone);

    //用户注册
    @FormUrlEncoded
    @POST("Login/register")
    Flowable<RegisterBean> register(
            @Field("password") String password,
            @Field("telephone") String telephone,
            @Field("code") String code);

    //用户登录
    @FormUrlEncoded
    @POST("Login/index")
    Flowable<LoginBean> login(
            @Field("password") String password,
            @Field("telephone") String telephone);

    //网关列表
    @GET("Network/index")
    Flowable<GatewayListBean> gatewayList(@Query("token") String token);

    //创建网关
    @FormUrlEncoded
    @POST("Network/addNetwork")
    Flowable<CommonBean> addGateway(
            @Field("token") String token,
            @Field("number") String number,//网关序列号
            @Field("title") String name,//网关名称
            @Field("username") String username,
            @Field("password") String password
    );

    //修改网关
    @FormUrlEncoded
    @POST("Network/updNetwork")
    Flowable<CommonBean> modifyGateway(
            @Field("token") String token,
            @Field("news_id") String gatewayId,//网关id
            @Field("title") String name//网关名称
    );

    //刪除網關
    @FormUrlEncoded
    @POST("device/del_gateway")
    Flowable<CommonBean> deleteGateway(
            @Field("token") String token,
            @Field("gateway_id") String gatewayId//网关id
    );

    //获取网关（授权）信息
    @GET("Network/detail")
    Flowable<GatewayDetailBean> gatewayDetail(
            @Query("token") String token,
            @Query("news_id") String gatewayId);

    //添加授权
    @FormUrlEncoded
    @POST("Network/addAuth")
    Flowable<CommonBean> addAuth(
            @Field("token") String token,
            @Field("news_id") String gatewayId,//网关id
            @Field("telephone") String telephone//被授权人账号
    );

    //删除授权
    @FormUrlEncoded
    @POST("Network/delAuth")
    Flowable<CommonBean> delAuth(
            @Field("token") String token,
            @Field("news_id") String gatewayId,//网关id
            @Field("telephone") String telephone//需要删除的授权人的姓名
    );

    //获取个人信息
    @GET("User/index")
    Flowable<UserBean> getUser(
            @Query("token") String token);

    //修改头像
    @Multipart
    @POST("User/updImg")
    Flowable<ModifyHeadBean> modifyHead(
            @Part("token") RequestBody token,
            @Part() MultipartBody.Part headPic);

    //验证码（修改密码）
    @FormUrlEncoded
    @POST("User/telCode")
    Flowable<CommonBean> getCodeByModifyPassword(
            @Field("telephone") String telephone);

    //修改密码
    @FormUrlEncoded
    @POST("User/updPassword")
    Flowable<CommonBean> modifyPassword(
            @Field("password") String password,
            @Field("telephone") String telephone,
            @Field("code") String code);

    //获取萤石云管理员账户token
    @POST("login/newGetToken")
    @FormUrlEncoded
    Flowable<BaseBean<String>> getAdminEzToken(@Field("token") String token, @Field("secret") String secret, @Field("appkey") String appkey);

    //获取当前accountId信息
    @POST("login/getSonAccountMsg")
    @FormUrlEncoded
    Flowable<BaseBean<EzAccountBean>> getSonAccountMsg(@Field("token") String token, @Field("accessToken") String accessToken);


    //创建萤石子账户
    @FormUrlEncoded
    @POST("login/createSonAccount")
    Flowable<BaseBean> createEzAccount(@Field("token") String token, @Field("accountName") String accountName, @Field("password") String password, @Field("accessToken") String accessToken);

    //在大账户添加萤石云设备
    @FormUrlEncoded
    @POST("Device/addDevice")
    Flowable<EzDeviceStateBean> addEzDevice(@Field("deviceSerial") String deviceSerial, @Field("validateCode") String validateCode);

    //在大账户删除萤石云设备
    @FormUrlEncoded
    @POST("Device/delDevice")
    Flowable<EzDeviceStateBean> deleteEzDevice(@Field("deviceSerial") String deviceSerial);

    //设置设备权限
    @FormUrlEncoded
    @POST("Login/ezDevicePolicy")
    Flowable<EzDevicePolicyBean> setEzDevicePolicy(@Field("accountId") String accountId, @Field("policy") String policy);

    //添加设备权限
    @FormUrlEncoded
    @POST("Login/sonAuthor")
    Flowable<BaseBean> addEzDevicePermission(@Field("accessToken") String accessToken, @Field("tel") String tel, @Field("to_tel") String toTel, @Field("statement") String statement);


    //删除设备权限
    @FormUrlEncoded
    @POST("login/CancelAuthor")
    Flowable<BaseBean> deleteEzDevicePermission(@Field("accessToken") String accessToken, @Field("tel") String tel, @Field("to_tel") String toTel, @Field("deviceSerial") String deviceSerial);

    //获取监控设备授权列表
    @FormUrlEncoded
    @POST("login/getDeviceList")
    Flowable<BaseBean<List<EzDeviceAuthorizationListBean>>> getEzDeviceAuthorzationList(@Field("accessToken") String accessToken, @Field("tel") String tel, @Field("to_tel") String toTel);

    //添加门锁授权
    @FormUrlEncoded
    @POST("Lock/lockAuthorizationAdd")
    Flowable<CommonBean> addDoorLockAuth(
            @Field("token") String token,
            @Field("gatewayId") String gatewayId,
            @Field("telephone") String telephone);


    //删除门锁授权
    @FormUrlEncoded
    @POST("Lock/lockAuthorizationDel")
    Flowable<CommonBean> delDoorLockAuth(
            @Field("token") String token,
            @Field("gatewayId") String gatewayId,
            @Field("telephone") String telephone);
    //门锁授权列表

    @GET("Lock/lockAuthorizationList")
    Flowable<DoorLockAuthBean> doorLockAuthList(
            @Query("token") String token,
            @Query("gatewayId") String gatewayId);

    //添加用户报警信息
    @FormUrlEncoded
    @POST("Msg/addReportMsg")
    Flowable<CommonBean> addMessage(
            @Field("token") String token,
            @Field("title") String title,
            @Field("content") String content);

    //用户报警信息列表
    @FormUrlEncoded
    @POST("Msg/getReportMsgList")
    Flowable<MessageListBean> messageList(
            @Field("token") String token);

    //用户信息未读数
    @FormUrlEncoded
    @POST("Msg/getUnreadMsgCount")
    Flowable<MessageCountBean> messageCount(
            @Field("token") String token);

    //阅读消息
    @FormUrlEncoded
    @POST("Msg/userReadMsgStatus")
    Flowable<CommonBean> readMessage(
            @Field("token") String token,
            @Field("messageId") String messageId);

    //登出
    @FormUrlEncoded
    @POST("Login/logout")
    Flowable<CommonBean> logout(
            @Field("token") String token);
}